#ifndef UModelH
#define UModelH
#include "stdafx.h"
#include "UVector.h"
#include "UFace.h"
#include <string>
#include <fstream>
#include <iostream>



/** BIG FAT WARNING: The current implementation will soon change! **/
/*
 *  The UModel class will become an internal (to the engine) representation
 *  of a model, abstracted from the way actual models (file formats) may
 *  be implemented. For each file format we want to support there will be
 *  specialised ModelLoader class which loads the model data and converts it
 *  to our internal format.
 *  We will start by implementing a SMD loader. SMD is a straightforward
 *  fileformat developed bij Valve for use in the HalfLife series of games.
 *      (See http://developer.valvesoftware.com/wiki/SMD_file_format)
 *
 *  Design goals for this internal format:
 *  (aka What I would love to be able to do with it, eventually)
 *   - Skeletal Animations (http://en.wikipedia.org/wiki/Skeletal_animation)
 *     if possible by using Vertex Shaders
 *   - Rag Doll Physics support (http://en.wikipedia.org/wiki/Ragdoll_physics),
 *     probably requires skeleton animations
 *   - Inverse Kinematics (as in http://edusworld.org/ew/ficheros/2006/paginasWeb/making_of_sotc.html,
 *     which, by the way, contains a wealth of info on kewl tr1ckz for our engine)
 *   - Use quaternions for rotations (supposedly this is faster)
 *   - Be able to render the animation in any point in time: interpolate between keyframes
 *   - Some way to incorporate Pixel Shaders into the model
 *   - <Insert more work here :) >
 *
 ********************************************************************/

/* Thinking of some classes ...
class Bone {
	private:
	public:
		Bone();
};

class Skeleton {
	private:
	public:
		Skeleton();
};

class Animation {
	private:
	public:
		Animation();
};

class Object {
	private:
	public:
		Object();
}; */

class TModel {
	private:
		void clearTriangles();
		void generateARBData();
		std::vector<TTriangle >* triangles;
		TVector minPoint, maxPoint; //defines a bounding box

		GLuint VBOARBTriangles;
		GLuint VBOARBNormals;
		GLuint VBOARBTexCoords;
		uint32 VBOARBVertexCount;
		void calculateBoundingBox();
		void drawBoundingBox();
	public:
		TModel();
		~TModel();
		void setTriangles( std::vector<TTriangle >* triangleList );
		void setTriangles( const std::vector<TTriangle >& triangleList );
		void draw();
		void draw(uint32 DebugFlags);
		uint32 vertexCount();
		TVector getMinPoint();
		TVector getMaxPoint();
		TVector getFurthestPoint();
		GLuint Texture;
};

#endif
